<script lang="ts" setup>
import { adminUrl } from '~/api/useHttp'

const menuList1 = [
  {
    name: '体重评估',
    url: '/otherPages/tool/toolTwo/toolTwo?inFrame=true',
    needLogin: false,
    mobilePage: true,

  },
  {
    name: '睡眠质量评估',
    url: '/questionnaire/survey/survey?formType=form&activity_no=20240627213526000001&status=进行中',
    needLogin: true,
    mobilePage: true,
  },
  {
    name: '孕期体重评估',
    url: '/publicPages/prettyForm/prettyForm?type=add&service=srvhealth_evaluate_pregnant_add&app=health&resultColumn=result',
    mobilePage: true,
    needLogin: true,
  },
  {
    name: '婴幼儿发育评估',
    url: '/questionnaire/survey/survey?formType=form&activity_no=20240625175248000001&status=进行中',
    mobilePage: true,
    needLogin: true,
  },
  {
    name: '中医九种体质评估',
    // url: '/archivesPages/healthCompose/healthCompose',
    url: `${adminUrl}/survey/#/pages/survey/index/pc?activity_no=20210702102421000002&status=进行中`,
    // url: 'http://localhost:8080/health/#/archivesPages/healthCompose/healthCompose',
    mobilePage: true,
    needLogin: true,
  },
  {
    name: '抑郁评估',
    url: '/questionnaire/survey/survey?formType=form&activity_no=20201116145316000198&status=进行中',
    mobilePage: true,
    needLogin: true,
  },
  {
    name: '焦虑评估',
    url: '/questionnaire/survey/survey?formType=form&activity_no=20201116151412000200&status=进行中',
    needLogin: true,
    mobilePage: true,

  },
]
const menuList2 = [{
  name: '冠心病评估',
  url: '/questionnaire/survey/survey?formType=form&activity_no=20240911085346000001&status=进行中',
  mobilePage: true,
  needLogin: true,
}, {
  name: '脑卒中评估',
  url: '/questionnaire/survey/survey?formType=form&activity_no=20240911095221000002&status=进行中',
  mobilePage: true,
  needLogin: true,
}, {
  name: '高血压评估',
  url: '/questionnaire/survey/survey?formType=form&activity_no=20240911150101000006&status=进行中',
  mobilePage: true,
  needLogin: true,
}, {
  name: '糖尿病评估',
  url: '/questionnaire/survey/survey?formType=form&activity_no=20240911102000000003&status=进行中',
  mobilePage: true,
  needLogin: true,
}, {
  name: '代谢综合征评估',
  url: '/questionnaire/survey/survey?formType=form&activity_no=20240911110735000004&status=进行中',
  mobilePage: true,
  needLogin: true,
}, {
  name: '癌症风险评估',
  url: '/questionnaire/survey/survey?formType=form&activity_no=20240911114109000005&status=进行中',
  mobilePage: true,
  needLogin: true,
}]

const menuList3 = [{
  name: '食物营养',
  url: '/views/custom/index/index?page_no=PG2410180003',
  dir: 'xmp',
  needLogin: true,
  mobilePage: true,
}, {
  name: '孕育营养',
  crowd_no: 'CD202101300002',
  url: '/views/custom/index/index?page_no=PG2410180003',
  needLogin: true,
  dir: 'xmp',
  mobilePage: true,

}, {
  name: '学龄儿童',
  crowd_no: 'CD202102170007',
  url: '/views/custom/index/index?page_no=PG2410180003',
  mobilePage: true,
  dir: 'xmp',
  needLogin: true,
}, {
  name: '办公室人群',
  crowd_no: 'CD202101300001',
  url: '/views/custom/index/index?page_no=PG2410180003',
  mobilePage: true,
  dir: 'xmp',
  needLogin: true,
}, {
  name: '老年人',
  crowd_no: 'CD202102170011',
  url: '/views/custom/index/index?page_no=PG2410180003',
  mobilePage: true,
  dir: 'xmp',
  needLogin: true,
}, {
  name: '糖尿病',
  crowd_no: 'CD2406220001',
  url: '/views/custom/index/index?page_no=PG2410180003',
  mobilePage: true,
  dir: 'xmp',
  needLogin: true,
}, {
  name: '高血压',
  crowd_no: 'CD2406220002',
  url: '/views/custom/index/index?page_no=PG2410180003',
  mobilePage: true,
  dir: 'xmp',
  needLogin: true,
}, {
  name: '痛风',
  crowd_no: 'CD2406220003',
  url: '/views/custom/index/index?page_no=PG2410180003',
  mobilePage: true,
  dir: 'xmp',
  needLogin: true,
}, {
  name: '肥胖',
  crowd_no: 'CD2406220004',
  url: '/views/custom/index/index?page_no=PG2410180003',
  mobilePage: true,
  dir: 'xmp',
  needLogin: true,
}]

function toPage(item: any) {
  console.log(item)
  if (item === '食品营养查询') {
    // const url = `http://139.196.111.15:9102/health/#/otherPages/dietSelect/dietSelect?condType=%25257B%252522type%252522%25253A%252522food%252522%25252C%252522serviceName%252522%25253A%252522srvhealth_diet_contents_select%252522%25252C%252522colName%252522%25253A%252522name%252522%25252C%252522imgCol%252522%25253A%252522image%252522%25252C%252522wordKey%252522%25253A%25257B%252522title%252522%25253A%252522name%252522%25252C%252522unit%252522%25253A%252522unit%252522%25252C%252522energy%252522%25253A%252522unit_energy%252522%25257D%25252C%252522pagetType%252522%25253A%252522detail%252522%25257D`
    // const url = `http://localhost:8080/xmp/#/views/custom/index/index?page_no=PG2410140004&srvApp=config`
    const url = `${adminUrl}/xmp/#/views/custom/index/index?page_no=PG2410140004&srvApp=config`
    navigateTo({
      path: '/peopleHealth/survey?title=食品营养',
      query: {
        title: '食品营养',
        webUrl: encodeURIComponent(url),
      },
    })
  }
  else if (item === '就医康复指引') {
    // const url = `http://localhost:8080/xmp/#/views/custom/bodyGuide/bodyGuide`
    const url = `${adminUrl}/xmp/#/views/custom/bodyGuide/bodyGuide`
    navigateTo({
      path: '/peopleHealth/survey',
      query: {
        title: '就医康复指引',
        webUrl: encodeURIComponent(url),
      },
    })
  }
  else {
    if (item.mobilePage === true) {
      let url = item.url
      if (item.url.indexOf('http') !== 0) {
        // url = `http://localhost:8080/${item.dir || 'health'}/#${item.url}`
        url = `${adminUrl}/${item.dir || 'health'}/#${item.url}`
      }
      if (item.crowd_no) {
        // url = `http://localhost:8080/xmp/#/views/custom/index/index?page_no=PG2411040001&crowd_no=${item.crowd_no}`
        url = `${adminUrl}/xmp/#/views/custom/index/index?page_no=PG2411040001&crowd_no=${item.crowd_no}`
      }
      // const { isLogin } = useUserStore()
      // if (item.needLogin && !isLogin) {
      //   ElMessage.error('请先登录')
      // }
      // else {
      if (url?.includes('activity_no')) {
        // 问卷 不填充上次选的值
        url += `&params=${encodeURIComponent(JSON.stringify({ emptyValue: true }))}`
      }
      navigateTo({
        path: '/peopleHealth/survey',
        query: {
          // webUrl: url,
          title: item.name,
          webUrl: encodeURIComponent(url),
        },
      })
      // }
    }
  }
}
</script>

<template>
  <div class="md:py-100px">
    <!-- <div class="absolute left-0 top-0 z--1 hidden w-full md:block" style="height:570px;background:linear-gradient(180deg, rgba(39,162,128,1) 0%,rgba(39,162,128,0) 100%);" />
    <div class="no-repeat absolute left-0 top-0 z--1 hidden h-540px w-full bg-[url(/img/bg-top.png)] bg-cover md:block" /> -->
    <div class="mx-auto max-w-1300px bg-white p-20px shadow-2xl md:rounded-10px">
      <div class="" grid="~ cols-1 gap-20px" md="grid-cols-2">
        <div class="cursor-pointer rounded-10px transition-all" hover="shadow scale-101 font-600" @click.stop="toPage('食品营养查询')">
          <img src="/img/spyycx.png" alt="">
        </div>
        <div class="cursor-pointer rounded-10px transition-all" hover="shadow scale-101 font-600" @click.stop="toPage('就医康复指引')">
          <img src="/img/jykfzy.png" alt="">
        </div>
      </div>
      <div class="mt-20px flex flex-col gap-20px" md="flex-row ">
        <div
          class="h-50px w-200px bg-[linear-gradient(88.92deg,_rgba(92,224,168,0.41)_1.07%,rgba(195,228,214,0.22)_99.94%)] text-center font-600 line-height-50px"
          border="l-3px solid #35B389"
        >
          健康自我评测
          <i class="i-carbon:triangle-right-solid ml-20px" />
        </div>
        <div class="flex-1" grid="~ gap-20px cols-[repeat(auto-fill,minmax(170px,_1fr))] gap-x-20px">
          <NuxtLink
            v-for="item in menuList1" :key="item.name"
            hover="shadow scale-105 font-600"
            class="cursor-pointer bg-#F3F5F9 text-center line-height-50px transition-all"
            @click="toPage(item)"
          >
            {{ item.name }}
          </NuxtLink>
        </div>
      </div>
      <div border="t-1px solid #E5E5EA" class="my-20px" />
      <div class="mt-20px flex flex-col gap-20px" md="flex-row ">
        <div
          class="h-50px w-200px bg-[linear-gradient(88.92deg,_rgba(92,224,168,0.41)_1.07%,rgba(195,228,214,0.22)_99.94%)] text-center font-600 line-height-50px"
          border="l-3px solid #35B389"
        >
          慢病风险评估
          <i class="i-carbon:triangle-right-solid ml-20px" />
        </div>
        <div class="flex-1" grid="~ gap-20px cols-[repeat(auto-fill,minmax(170px,_1fr))] gap-x-20px">
          <NuxtLink
            v-for="item in menuList2" :key="item.name"
            hover="shadow scale-105 font-600"
            class="cursor-pointer bg-#F3F5F9 text-center line-height-50px transition-all"
            @click="toPage(item)"
          >
            {{ item.name }}
          </NuxtLink>
        </div>
      </div>
      <div border="t-1px solid #E5E5EA" class="my-20px" />
      <div class="mt-20px flex flex-col gap-20px" md="flex-row ">
        <div
          class="h-50px w-200px bg-[linear-gradient(88.92deg,_rgba(92,224,168,0.41)_1.07%,rgba(195,228,214,0.22)_99.94%)] text-center font-600 line-height-50px"
          border="l-3px solid #35B389"
        >
          食品药品指引
          <i class="i-carbon:triangle-right-solid ml-20px" />
        </div>
        <div class="flex-1" grid="~ gap-20px cols-[repeat(auto-fill,minmax(170px,_1fr))] gap-x-20px">
          <NuxtLink
            v-for="item in menuList3" :key="item.name"
            hover="shadow scale-105 font-600"
            class="cursor-pointer bg-#F3F5F9 text-center line-height-50px transition-all"
            @click="toPage(item)"
          >
            {{ item.name }}
          </NuxtLink>
        </div>
      </div>
    </div>
  </div>
</template>

<style>

</style>
